package com.cy.aircompressor.main.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.cy.aircompressor.databinding.NoDataViewBinding;

public class NoDataView extends FrameLayout {
    public NoDataView(@NonNull Context context) {
        this(context, null);
    }

    public NoDataView(@NonNull Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public NoDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        this(context, attrs, defStyleAttr, 0);
    }

    public NoDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        initView();
    }


    private void initView() {
        NoDataViewBinding noDataViewBinding = NoDataViewBinding.inflate(LayoutInflater.from(getContext()));
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        addView(noDataViewBinding.getRoot(), layoutParams);
        dismiss();
    }

    public void show(){
        this.setVisibility(VISIBLE);
    }

    public void dismiss(){
        this.setVisibility(GONE);
    }
}
